
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkgjeudestrategie;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.OverlayLayout;

/**
 *
 * @author Admin
 */
public class Fenetre extends JFrame {

    

    private EcranInfos informationScreen;
    private EcranStats ecranStats;
    private Jeu jeu;
    private EscButton escButton;
    static private Toolkit toolkit = Toolkit.getDefaultToolkit();
    static final Dimension scrnsize = toolkit.getScreenSize();
    static final int tailleX = (int) scrnsize.getWidth();
    static final int tailleY = (int) scrnsize.getHeight();
    MenuTitre menu;
    int nbPlayer = 2;
    JLayeredPane layeredPane;
    boolean newGame;
    
    public Fenetre() {
        setSize(tailleX, tailleY);
        
        setTitle("Jeu de stratégie");
        menu = new MenuTitre(this);

        add(menu);
        setUndecorated(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);

    }

    public void nouveauJeu(boolean newGame) {
       
        this.remove(menu);
        setLayout(null);
        
        
        informationScreen = new EcranInfos(this);
        ecranStats = new EcranStats();
        jeu = new Jeu(informationScreen, nbPlayer,ecranStats, newGame,this);
        escButton=new EscButton(jeu);
        jeu.setEscButton(escButton);
        //informationScreen.requestFocus();
        jeu.requestFocusInWindow();
        
        informationScreen.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        informationScreen.setLocation(0, 0);
        
        layeredPane = new JLayeredPane();
        layeredPane.setBounds(200,0,tailleX,tailleX);
        
        
        add(informationScreen);
        add(layeredPane);
        layeredPane.setLayout(null);
        layeredPane.add(escButton,new Integer(1),0);
        layeredPane.add(ecranStats,new Integer(1),0);
        escButton.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        escButton.setBounds(tailleX-550,0,550,30);
        ecranStats.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        ecranStats.setBounds(tailleX-550,30,550,30);
        layeredPane.add(jeu, new Integer(0),0);
        jeu.setBounds(0,0,tailleX,tailleX);
        
        layeredPane.setVisible(true);
        ecranStats.setVisible(true);
        jeu.setVisible(true);
        informationScreen.setVisible(true);
        escButton.setVisible(true);

        this.invalidate();
        this.repaint();


    }

    public void restart(){
        removeAll();
        menu = new MenuTitre(this);

        add(menu);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
        invalidate();
        repaint();
        revalidate();
    }

    public Jeu getJeu() {
        return jeu;
    }
}